<?php
class Start_Model
{
	/**
	 * Holds instance of database connection
	 */
	private $db;
	private $news_number;
		
	public function __construct()
	{
		$this->db = new MysqlImproved_Driver;
	}
	
	/**
	 * Fetches article based on supplied name
	 * 
	 * @param string $author
	 * 
	 * @return array $article
	 */
	public function get_article()
	{		
		//connect to database
		$this->db->connect();
		$this->get_page_data();
		$article['page_title'] = $this->page_data['title'];
		$article['page_description'] = $this->page_data['description'];
		$article['page_keywords'] = $this->page_data['keywords'];
		$article['content'] = $this->get_articles();
		return $article;
	}
	
	
		
	public function get_articles(){
		$this->db->prepare(
				"
				SELECT
				`article_title`,
				`article_link`,
				`article_description`,
				`article_image`
				FROM
				`articles`
				ORDER
				BY
				`id`
				DESC
				;
				"
		);
		$this->db->query();
		$articles = "";
		while($article_data = $this->db->fetch('array')){
			$articles .= "
				
				<!-- Begin Slider Item -->
				<div class=\"slider-item\">
					<div class=\"featured-img-wrap\"><img class=\"featured-img\" src=\"".$article_data['article_image']."\" alt=\"".$article_data['article_title']."\" /></div>
					<h3><a href=\"/articles/".$article_data['article_link'].".html\">".$article_data['article_title']."</a></h3>
					<div class=\"featured-parag\">
						".$latest_service_data['article_description']."
					</div>
				</div>
				<!-- End Slider Item -->
			";
		}
		return $articles;
	}
	public function get_page_data(){
		//prepare query
		$this->db->prepare
		(
				"
				SELECT
				`page`,
				`title`,
				`description`,
				`keywords`
				FROM
				`page_description`
				WHERE
				`page` = 'start'
				LIMIT
				1
				;
				"
		);
	
		//execute query
		$this->db->query();
	
		$this->page_data = $this->db->fetch('array');
		return $this->page_data;
	}
	
}